//cardtest1 -- great hall
//Getting seg fault ??
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>

int main(int argc, char const *argv[])
{
	//player, state, card, handPos -- set state.numActions
	int card = 16;
	int player;
	struct gameState state;
	int handPos;
	int i, j, checkact, checkcount, r;
	int b = 0;
	int *bonus = &b;

	for(i= 0 ; i < 2000; i++){
		for (j = 0; j < sizeof(struct gameState); j++) {
			((char*)&state)[i] = floor(Random() * 256);
		}
		player = rand() % 5;
		state.numActions = rand() % 10;
		checkact = state.numActions;
		state.handCount[player] = rand() % MAX_HAND;
		checkcount = state.handCount[player];
		for(j = 0; j < state.handCount[player]; j++){
			state.hand[player][j] = rand() % 27;
		}
		handPos = rand() % state.handCount[player];
		state.hand[player][handPos] = card;
		r = cardEffect(card, 0, 0, 0, &state, handPos, bonus);
		assert(r == 0);
		if(checkact + 1 == state.numActions){
			if(checkcount == state.handCount[player]){ //add a card, discard a card, handCount should be equal before/after
				printf("Pass\n");
			} else {
				printf("Failed: hand count\n");
			}
		} else {
			printf("Failed: add action\n");
		}
	}
	return 0;
}